#include "MasterOwnedStates.h"
#include "State.h"
#include "Master.h"
#include "Locations.h"

#include <iostream>
using std::cout;

////////////////////////////////////////////////////
/////////////////Oasis and Meditate/////////////////////
////////////////////////////////////////////////////

VisitOasisAndMeditate* VisitOasisAndMeditate::Instance()
{
	static VisitOasisAndMeditate instance;

	return &instance;
}

void VisitOasisAndMeditate::Enter(Master* pMaster)
{

	if(pMaster->funcLocation() != Oasis)
	{
		//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nMaster: Going to visit the Oasis.";

		pMaster->ChangeLocation(Oasis);
	}
}



void VisitOasisAndMeditate::Execute(Master* pMaster)
{  
	pMaster->DecreaseDiscomfort();
	pMaster->IncreaseThirst();
	pMaster->IncreaseFatigue();
	pMaster->InputMessage("Went to Meditate");
	
	cout << "\nLast Turn My Apprentice : " << pMaster->OutputApprenticeMessage();

	//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
	cout << "\nMaster: Ah... The sounds of Nature.";


	pMaster->FindActivity(); //Makes the Character figure out what he should do next.


}

void  VisitOasisAndMeditate::Exit(Master* pMaster)
{
	if(pMaster->pStateMachine->CurrentState() != VisitOasisAndMeditate::Instance())
	{
	//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nMaster: Nothing like the sounds of the oasis to calm ones mind.";
	}
}


////////////////////////////////////////
//////////////////Drink/////////////////
////////////////////////////////////////

VisitOasisAndDrink* VisitOasisAndDrink::Instance()
{
	static VisitOasisAndDrink instance;

	return &instance;
}


void VisitOasisAndDrink::Enter(Master* pMaster)
{
	if(pMaster->funcLocation() != Oasis)
	{
		//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nMaster: Going to the Oasis.";

		pMaster->ChangeLocation(Oasis);
	}
}



void VisitOasisAndDrink::Execute(Master* pMaster)
{  
	pMaster->DecreaseThirst();

	pMaster->IncreaseHunger();
	pMaster->IncreaseDiscomfort();
	pMaster->InputMessage("Went to Drink");
	
	cout << "\nLast Turn My Apprentice : " << pMaster->OutputApprenticeMessage();

	//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
	cout << "\nMaster: Such crisp water.";



	pMaster->FindActivity(); //Makes the Master figure out what he should do next.


}

void  VisitOasisAndDrink::Exit(Master* pMaster)
{
	if(pMaster->pStateMachine->CurrentState() != VisitOasisAndDrink::Instance())
	{
	//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nMaster: Well, that was refreshing, now to my other matters.";
	}
}



/////////////////////////
///////////Sleep/////////
/////////////////////////
VisitTownAndSleep* VisitTownAndSleep::Instance()
{
	static VisitTownAndSleep instance;

	return &instance;
}

void VisitTownAndSleep::Enter(Master* pMaster)
{

	if(pMaster->funcLocation() != Town)
	{
		//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nMaster: Going to Town to sleep.";

		pMaster->ChangeLocation(Town);
	}
}

void VisitTownAndSleep::Execute(Master* pMaster)
{  
		pMaster->DecreaseFatigue();

		pMaster->IncreaseThirst();
		pMaster->IncreaseHunger();
		cout << "\nMaster: *Snore, Snore*";
		pMaster->InputMessage("Went to Sleep");
	
	cout << "\nLast Turn My Apprentice : " << pMaster->OutputApprenticeMessage();

	pMaster->FindActivity();

}

void  VisitTownAndSleep::Exit(Master* pMaster)
{
	if(pMaster->pStateMachine->CurrentState() != VisitTownAndSleep::Instance())
	{
	//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nMaster: Well that was refreshing! Back to life.";
	}
}
/////////////////////////
///////////Work/////////
/////////////////////////
VisitTownAndWork* VisitTownAndWork::Instance()
{
	static VisitTownAndWork instance;

	return &instance;
}

void VisitTownAndWork::Enter(Master* pMaster)
{

	if(pMaster->funcLocation() != Town)
	{
		//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nMaster: Going to Town to work..";

		pMaster->ChangeLocation(Town);
	}
}



void VisitTownAndWork::Execute(Master* pMaster)
{  
	pMaster->DecreasePoverty();
		
	pMaster->IncreaseFatigue();
	pMaster->IncreaseHunger();
	pMaster->IncreaseThirst();
	pMaster->IncreaseDiscomfort();
	pMaster->InputMessage("Went to Work");

	cout << "\nLast Turn My Apprentice : " << pMaster->OutputApprenticeMessage();
	
	cout << "\nMaster: Thank you, come again!";

	pMaster->FindActivity();
}

void  VisitTownAndWork::Exit(Master* pMaster)
{
	if(pMaster->pStateMachine->CurrentState() != VisitTownAndWork::Instance())
	{
	//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nMaster: Well work was boring... But at east I got some money!";
	}
}

//--------------------------------------methods for VisitJungleAndScavenge	//BRANDON ROCKWELL -7/25/2010 9:42 P.M.

VisitJungleAndScavenge* VisitJungleAndScavenge::Instance()
{
	static VisitJungleAndScavenge instance;

	return &instance;
}
void VisitJungleAndScavenge::Enter(Master* pMaster)
{

	if(pMaster->funcLocation() != Jungle)
	{
		//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nMaster: Going to the Jungle";

		pMaster->ChangeLocation(Jungle);
	}
}


void VisitJungleAndScavenge::Execute(Master* pMaster)
{  

	//This if statement isn't going to work
	//the compiler has no idea what pMaster is, nor does the apprentice have a HuntedCounter function/variable
	//this will require a messenger that can talk to both master and Master, so for now, leave this state alone
	//-Strog

	if(pMaster->HuntedCheck()!=0) //Checks to see if hunting has happened in the last 5 minutes.
	{
		pMaster->DecreaseHunger();
		pMaster->DecreaseHunger();

		pMaster->IncreaseThirst();

			//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
			cout << "\nMaster: OMMING MY NOM";
			pMaster->InputMessage("Went to Scavenge Meat");
	}

	else
	{
		pMaster->DecreaseHunger();

		pMaster->IncreaseFatigue();

			//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
			cout << "\nMaster: Gathering Berries";
			pMaster->InputMessage("Went to Scavenge Berries");
	}
	cout << "\nLast Turn My Apprentice : " << pMaster->OutputApprenticeMessage();


	pMaster->FindActivity(); //Makes the Master figure out what he should do next.
}

void VisitJungleAndScavenge::Exit(Master* pMaster)
{
	if(pMaster->pStateMachine->CurrentState() != VisitJungleAndScavenge::Instance())
	{
	//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nMaster: That was delicious, but I've got other things to attend to now.";
	}
}

///////////////////////////////////////////////////////////////
//////////////////Deposit//////////////////////////////////////
///////////////////////////////////////////////////////////////



VisitTownAndDonate* VisitTownAndDonate::Instance()
{
	static VisitTownAndDonate instance;

	return &instance;
}
void VisitTownAndDonate::Enter(Master* pMaster)
{

	if(pMaster->funcLocation() != Town)
	{
		//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nMaster: Going to Town";

		pMaster->ChangeLocation(Town);
	}
}


void VisitTownAndDonate::Execute(Master* pMaster)
{  

	pMaster->DonateMoney();


	//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
	cout << "\nMaster: Giving money to the orphans";
	pMaster->InputMessage("Donated to the Poor");
	cout << "\nLast Turn My Apprentice : " << pMaster->OutputApprenticeMessage();


	pMaster->FindActivity(); //Makes the Master figure out what he should do next.
}

void VisitTownAndDonate::Exit(Master* pMaster)
{
	if(pMaster->pStateMachine->CurrentState() != VisitTownAndDonate::Instance())
	{
	//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nMaster: That was delicious, but I've got other things to attend to now.";
	}
}









/////////////////////////
///////////Hunt//////////
/////////////////////////
//VisitJungleAndHunt* VisitJungleAndHunt::Instance()
//{
//	static VisitJungleAndHunt instance;
//
//	return &instance;
//}

//void VisitJungleAndHunt::Enter(Master* pMaster)
//{
//
//	if(pMaster->funcLocation() != Jungle)
//	{
//		//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
//		cout << "\nMaster: Going to the Jungle.";
//
//		pMaster->ChangeLocation(Jungle);
//	}
//}
//
//
//
//void VisitJungleAndHunt::Execute(Master* pMaster)
//{  
//	if(pMaster->Hungry())
//	{
//		pMaster->HuntedReset();
//		pMaster->DecreaseHunger();
//		pMaster->IncreaseFatigue();
//		cout << "Killing some boar";
//	}
//
//	if(!pMaster->Hungry())
//	{
//		pMaster->FindActivity(); //Makes the Master figure out what he should do next.
//	}
//}
//
//void  VisitJungleAndHunt::Exit(Master* pMaster)
//{
//	//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
//	cout << "\nThats enough killing for now.";
//}
//
//
//
//
//


















//////////////////////////////////////////////////////////
/////////Commented out till its ready to use//////////////
/////////Delete this comment along with the///////////////
/////////revision of MasterOwnedStates////////////////////
//////////////////////////////////////////////////////////





//
//VisitTownAndWork* VisitTownAndWork::Instance()
//{
//	static VisitTownAndWork instance;
//
//	return &instance;
//}
//
//void VisitTownAndWork::Enter(Master* pMaster)
//{
//
//	if(pMaster->funcLocation() != Town)
//	{
//		//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
//		cout << "\nMaster: Going to Town";
//
//		pMaster->ChangeLocation(Town);
//	}
//}
//
//
//
//void VisitTownAndWork::Execute(Master* pMaster)
//{
//	pMaster->DecreasePoverty(1);   //Adds one to iMoney
//
//	pMaster->IncreaseFatigue(1); //Adds one to Fatigue
//
//	cout << "\nMaster: Working in Town";
//
//	//pMaster->FindActivity(); //Makes the Master figure out what he should do next.
//}
//
//
//void VisitTownAndWork::Exit(Master* pMaster)
//{
//	//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
//	cout << "\nMaster: That was a Hard Day at work.";
//}
//
/////////////////////////////////////////////////////////////////
//
////--------------------
////Master Drink State
////--------------------
//VisitOasisAndDrink* VisitOasisAndDrink::Instance()
//{
//	static VisitOasisAndDrink instance;
//
//	return &instance;
//}
//
//
//void VisitOasisAndDrink::Enter(Master* pMaster)
//{
//	if(pMaster->funcLocation() != Oasis)
//	{
//		//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
//		cout << "\nMaster:: Going to the Oasis.";
//
//		pMaster->ChangeLocation(Oasis);
//	}
//}
//
//
//
//void VisitOasisAndDrink::Execute(Master* pMaster)
//{  
////	while(pMaster->Thirsty()> 0)
////	{
////
////		pMaster->DecreaseThirst(1);
////
////		pMaster->IncreaseFatigue(1);
////
////		//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
////		cout << "\nMaster:: That's some good water.";
////	}
//
//
//	//if(pMaster->Thirsty()<=0)
//	//{
//	//	//pMaster->FindActivity(); //Makes the Master figure out what he should do next.
//	//}
//
//}
//
//void  VisitOasisAndDrink::Exit(Master* pMaster)
//{
//	//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
//	cout << "\nMaster:: Well, that was refreshing, now to my other matters.";
//}
//
//
////-----------------
////Drink State End
////-----------------
//
//
//
////--------------------
////Master Meditate State
////--------------------
//VisitOasisAndMeditate* VisitOasisAndMeditate::Instance()
//{
//	static VisitOasisAndMeditate instance;
//
//	return &instance;
//}
//void VisitOasisAndMeditate::Enter(Master* pMaster)
//{
//	pMaster->ChangeLocation(Oasis);
//}
//
//
//void VisitOasisAndMeditate::Execute(Master* pMaster)
//{  
//	//while(pMaster->Uncomfortable()> 0)
//	//{
//
//	//	pMaster->DecreaseDiscomfort(1);
//
//	//	pMaster->IncreaseFatigue(1);
//
//	//	//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
//	//	cout << "\nMaster:: The sound of the oasis are so soothing...";
//	//}
//
//
//	//if(pMaster->Uncomfortable()<=0)
//	//{
//	//	//pMaster->FindActivity(); //Makes the Master figure out what he should do next.
//	//}
//
//}
//
//void  VisitOasisAndMeditate::Exit(Master* pMaster)
//{
//	//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
//	cout << "\nMaster:: Nothing like a bit of quiet to soothe the mind, back to work.";
//}
//
//
////-----------------
////Meditate State End
////-----------------
//
////-----------------
////Sleep State Begin
////-----------------
//
//VisitTownAndSleep* VisitTownAndSleep::Instance()
//{
//	static VisitTownAndSleep instance;
//
//	return &instance;
//}
//
//
//void VisitTownAndSleep::Enter(Master* pMaster)
//{
//	if(pMaster->funcLocation() != Town)
//	{
//		//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
//		cout << "\nMaster: Going to the Town now.";
//
//		pMaster->ChangeLocation(Town);
//	}
//}
//
//
//
//void VisitTownAndSleep::Execute(Master* pMaster)
//{  
//	//while(pMaster->Fatigued()> 0)
//	//{
//
//	//	pMaster->IncreaseThirst(1);
//
//	//	pMaster->DecreaseFatigue(1);
//
//	//	//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
//	//	cout << "\nMaster: *Snore, Snore*";
//	//}
//
//
//	//if(pMaster->Thirsty()<=0)
//	//{
//	//	//pMaster->FindActivity(); //Makes the Master figure out what he should do next.
//	//}
//
//}
//
//void  VisitTownAndSleep::Exit(Master* pMaster)
//{
//	//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
//	cout << "\nMaster:: Ah, nice and awake now... Back to life.";
//}
//
////-----------------
////Sleep State End
////-----------------